import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class LicenseService {
    constructor(private requestclass: RequestClass) {}
    fetchLicenseByConfig = async ({ applicantName, end, license, start }) => {
        return await this.requestclass.request.Pget('/license/getlicenseinfo', {
          params: {
            applicantName,
            end,
            license,
            start,
          },
        })
      }
      
      deleteLicenseById = async ({ licenseId }) => {
        return await this.requestclass.request.delete('/license/deletelicenseinfo', {
          params: {
            licenseId,
          },
        })
      }
      
      editLicenseByConfig = async ({
        applicantId,
        available,
        departmentId,
        id,
        license,
        licenseVolume,
        startTime,
      }) => {
        return await this.requestclass.request.put('/license/updatelicenseinfo', {
          data: {
            applicantId,
            available,
            departmentId,
            id,
            license,
            licenseVolume: (licenseVolume || 0) * 10000,
            startTime,
          },
        })
      }
      
     addLicenseByConfig = async ({
        applicantId,
        available,
        departmentId,
        license,
        licenseVolume,
        startTime,
      }) => {
        return await this.requestclass.request.post('/license/insertlicenseinfo', {
          data: {
            applicantId,
            available,
            departmentId,
            license,
            licenseVolume: (licenseVolume || 0) * 10000,
            startTime,
          },
        })
      }
      
}